package demo.serializable.demo1;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

public class SaveObject {

	public static void main(String args[]) throws FileNotFoundException,
			IOException, ClassNotFoundException {
		ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(
				new File("D://objectFile.obj")));

		DataObject ob = new DataObject();
		ob.setName("1");

		SavaData data = new SavaData();
		data.setObject(ob);

		out.writeObject(data);
		out.close();

		ObjectInputStream in = new ObjectInputStream(new FileInputStream(
				"D://objectFile.obj"));

		SavaData ob2 = (SavaData) in.readObject();
		System.out.println(((DataObject) ob2.getObject()).getName());
	}

}
